﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.CRM.Component.Common;
using TRPOP.CRM.Component.Business;
using TRPOP.CRM.Component.Model;
using TRPOP.Common;

namespace TRPOP.CRM.Web
{
    /// <summary>
    /// 客户等级列表页
    /// </summary>
    public partial class CompanyGrade_list : BaseAdmin
    {
        #region 权限限制
        protected override void SubPageInit()
        {
            base.m_oCurrentPermissionKey = "Sys_CompanyGrade";
        }
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        //delete CompanyGrade By ID
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = (LinkButton)sender;
            int intCompanyGradeID = lbtn.CommandArgument.ToInt();

            //根据CompanyGradeID重新获取实体
            CompanyGradeInfo oCompanyGradeInfo = TRPOP.CRM.Component.Business.BaseManage.GetCompanyGradeInfoByID(intCompanyGradeID);
            if (oCompanyGradeInfo != null)
            {
                oCompanyGradeInfo.bIsDelete = true;
                if (TRPOP.CRM.Component.Business.BaseManage.SaveCompanyGradeInfo(oCompanyGradeInfo))
                {
                    Alert("删除成功");
                }
                else
                {
                    Alert("删除失败");
                }
            }
            BindData();      
        }
        #endregion

        #region 页面方法

        /// <summary>
        ///Bind CompanyGrade By blsDelete=false 
        /// </summary>
        protected void BindData()
        {
             rptList.DataSource = TRPOP.CRM.Component.Business.BaseManage.GetAllCompanyGradeInfo();
             rptList.DataBind();
            
        }
        #endregion
    }
}